//
//  TutorIndexTableViewCell.m
//  YXFinance
//
//  Created by uplooking on 2018/10/23.
//  Copyright © 2018年 CRLong. All rights reserved.
//

#import "TutorIndexTableViewCell.h"

@interface TutorIndexTableViewCell()
{
    UIImageView * imageView;
    UILabel * labelName;
    UILabel * labelTitle;
    UILabel * labelTime;
}
@end

@implementation TutorIndexTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self initView];
    }
    
    return  self;
}

- (void)initView{
    
    imageView = [[UIImageView alloc]init];
    [self addSubview:imageView];
    [imageView.layer setMasksToBounds:YES];
    [imageView.layer setCornerRadius:8.0 * kAutoScanleX];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(15 * kAutoScanleX);
        make.size.mas_equalTo(CGSizeMake(100 * kAutoScanleX, 74 * kAutoScanleX));
    }];

    
    
    labelName = [[UILabel alloc]init];
    [labelName setTextColor:HexRGBA(0x000000, 1)];
    [labelName setFont:[UIFont systemFontOfSize:16 * kAutoScanleX]];
    [labelName setTextAlignment:NSTextAlignmentLeft];
    [self addSubview:labelName];
    [labelName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageView.mas_right).offset(15 * kAutoScanleX);
        make.top.equalTo(imageView).offset(5 * kAutoScanleX);
    }];
    
    
    labelTitle = [[UILabel alloc]init];
    [labelTitle setTextColor:HexRGBA(0x585858, 1)];
    [labelTitle setFont:[UIFont systemFontOfSize:14 * kAutoScanleX]];
    [labelTitle setTextAlignment:NSTextAlignmentLeft];
    [self addSubview:labelTitle];
    [labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageView.mas_right).offset(15 * kAutoScanleX);
        make.right.equalTo(self).offset(-15 * kAutoScanleX);
        make.top.equalTo(labelName.mas_bottom).offset(10 * kAutoScanleX);
    }];
    
    labelTime = [[UILabel alloc]init];
    [labelTime setTextColor:HexRGBA(0xa4a4a4, 1)];
    [labelTime setFont:[UIFont systemFontOfSize:12 * kAutoScanleX]];
    [labelTime setTextAlignment:NSTextAlignmentLeft];
    [self addSubview:labelTime];
    [labelTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageView.mas_right).offset(15 * kAutoScanleX);
        make.right.equalTo(self).offset(-15 * kAutoScanleX);
        make.top.equalTo(labelTitle.mas_bottom).offset(5 * kAutoScanleX);
    }];
    
    
    
    UIView *line = [[UIView alloc]init];
    [line setBackgroundColor:HexRGBA(0xcfd4db, 1)];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.left.right.equalTo(self).inset(15 * kAutoScanleX);
        make.height.mas_equalTo(0.5);
    }];
    
}

- (void)setModel:(NewsIndexModel *)model{
    
    [imageView sd_setImageWithURL:[NSURL URLWithString:model.litpic] placeholderImage:[UIImage imageNamed:@"bg_list_moren"]];
    [labelName setText:model.slug];
    [labelTitle setText:model.title];
    [labelTime setText:model.addtime];
    
}

@end
